from base.level import BaseLevel
from manager import sprite_mgr
from settings import *
from src.static import GenericStatic, ArmStatic
from tools import create_sprite_dict


class Level(BaseLevel):
    def setup(self):
        print("level setup .....")
        GenericStatic(
            (0, 0),
            create_sprite_dict(PGLevel.level1.value)[0],
            self.display_groups,
            z=PGLayers.ground.value)
        for x, y, surf in sprite_mgr.tmx_load_by_name("wall").tiles():
            GenericStatic((x * TILE_SIZE, y * TILE_SIZE), surf, self.update_groups, z=PGLayers.main.value)
        for x, y, surf in sprite_mgr.tmx_load_by_name('collision').tiles():
            GenericStatic((x * TILE_SIZE, y * TILE_SIZE), PG.Surface((TILE_SIZE, TILE_SIZE)), self.collision_groups)

    def run(self, dt):
        self.display_surface.fill('black')
        self.display_groups.draw(self.display_surface)
        self.update_groups.custom_draw()
        self.update_groups.update(dt)
        self.arms.display(self.player.arm_index)
        self.skills.display(self.player.skill_index)
